package org.wmine.algo;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class clustering extends JFrame
{String classLbl="";
 JTextField tf;
	public clustering(final String[]attribs,final int colknt,final int cntRow,final String [][]dataValues,final int[]selected)
	{
		final Container c=this.getContentPane();
		this.setTitle("Clustering by k-means");
		JPanel mainPanel=new JPanel();
		mainPanel.setLayout(null);

		JPanel pan1=new JPanel();
		pan1.setLayout(null);
		pan1.setBounds(10,10,330,180);

		JLabel lab1=new JLabel("Number of Clusters:");
		lab1.setBounds(10,10,140,30);
		tf=new JTextField();
		tf.setBounds(143,17,120,20);
		pan1.add(lab1);
		pan1.add(tf);

		JLabel lab2=new JLabel("Selection of Seeds:");
		lab2.setBounds(10,40,140,30);
		final JComboBox com1=new JComboBox();
		com1.addItem(new String("Manually"));
		com1.addItem(new String("Automatically"));//using agglomorative
		com1.setEditable(false);
		com1.setBounds(143,45,120,20);
		com1.setSelectedIndex(0);
		classLbl=com1.getSelectedItem().toString();
		com1.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e){classLbl=e.getItem().toString();System.out.println(classLbl);}});
		com1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent ae){System.out.println(com1.getSelectedIndex()+","+com1.getSelectedItem().toString());}});
		pan1.add(lab2);
		pan1.add(com1);
		
	/*	mainPanel.add(new JLabel(""));mainPanel.add(new JLabel("Select the Attributes:"));
		cb111=new JCheckBox[colknt];checkCnt=new int[colknt];
		ActionListener listener=new ActionListener(){public void actionPerformed(ActionEvent ae){update();}};
		for(i = 0;i<colknt;i++)
		{
			cb111[i]=new JCheckBox(attribs[i]);
			cb111[i].addActionListener(listener);
			mainPanel.add(cb111[i]);
		}*/
		
		JButton but1=new JButton("Process");
		JButton but2=new JButton("Cancel");
		but1.setBounds(30,90,90,25);
		but2.setBounds(135,90,80,25);
		pan1.add(but1);
		pan1.add(but2);
		but1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent ae)
		{
			//com1.get
			dispose();
			JOptionPane.showMessageDialog(null, classLbl+tf.getText()+colknt);
			System.out.println("goinggggggg");
			clusteringNext sd=new clusteringNext(attribs,colknt,cntRow,dataValues,classLbl,tf.getText(),selected);
		//	sd.setBounds(350,300,310,180);
			sd.setVisible(true);
			System.out.println("goooooooone");
			//ProgressBar pb=new ProgressBar();
			//pb.getDialog();
		}});
		mainPanel.add(pan1);
		c.add(mainPanel);
		
	}

	public static void main(String [] args)
	{}
}